package org.finesys.common.xss.config;

import org.finesys.common.xss.filter.XssFilter;
import org.finesys.common.xss.properties.XssProperties;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.util.PathMatcher;

@AutoConfiguration
@EnableConfigurationProperties(XssProperties.class)
public class XssAutoConfig {

    /**
     * 注册xssBean
     */
    @Bean
    public FilterRegistrationBean<XssFilter> xssFilter(XssProperties xssProperties, PathMatcher pathMatcher) {
        FilterRegistrationBean<XssFilter> registrationBean = new FilterRegistrationBean<XssFilter>();
        registrationBean.setFilter(new XssFilter(xssProperties, pathMatcher));
        registrationBean.setOrder(-105);
        return registrationBean;
    }


}
